import React from "react";
import { createRoot } from "react-dom/client";
import { GlobalStyle } from "./styles";
import { getValueOrDie } from "@common/utils";
import { AppCore } from "@/ui/AppCore";
import { XHSApp } from "@/ui/cpts/biz/XHSApp";
import { initRPCService } from "@common/utils/initRPCService";
import events from "@/ui/events";
import { Toaster } from "@shadcn/sonner";
import { ConfigProvider } from "antd";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import "dayjs/locale/zh-cn";
import zhCN from "antd/locale/zh_CN";

dayjs.extend(relativeTime).locale("zh-cn");

initRPCService(events.Global, {}, "ui");
new AppCore();

// 渲染你的 React 组件
const root = createRoot(getValueOrDie(document.getElementById("app")));
root.render(
  <React.StrictMode>
    <GlobalStyle />
    <ConfigProvider
      locale={zhCN}
      theme={{
        token: {
          colorPrimary: "black",
          fontSize: 12,
        },
      }}
    >
      <XHSApp />
    </ConfigProvider>
    <Toaster />
  </React.StrictMode>,
);
